connectd/tests: fix test_announce_and_connect_via_dns on macOS#9143
Open
nGoline wants to merge 1 commit into
Open
connectd/tests: fix test_announce_and_connect_via_dns on macOS#9143nGoline wants to merge 1 commit into
nGoline wants to merge 1 commit into
Conversation
65e7503 to
89d3d46
Compare
Two issues caused this test to fail or produce BROKEN log messages on macOS: 1. macOS does not include 'localhost.localdomain' in /etc/hosts by default, so the test's DNS-resolve step fails immediately. Skip with a clear message if the hostname is not resolvable. 2. On macOS/BSD, AI_ADDRCONFIG is implemented by opening temporary probe sockets to test IPv4/IPv6 connectivity. Those sockets are not registered with the io framework, so dev_report_fds() flags them as unowned (BROKEN). Guard AI_ADDRCONFIG with #ifndef __APPLE__ so Linux keeps the optimization while macOS avoids the fd-leak. Changelog-None Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
89d3d46 to
b7b271c
Compare
ddustin
requested changes
Jun 18, 2026
| socket.getaddrinfo('localhost.localdomain', 12345, 0, socket.SOCK_STREAM) | ||
| except socket.gaierror: | ||
| pytest.skip("localhost.localdomain not resolvable; add '127.0.0.1 localhost.localdomain' to /etc/hosts") | ||
|
|
Collaborator
There was a problem hiding this comment.
Instead of skipping the test, I think we might be able to use "test.localhost," as mac allows subdomains on localhost. If that doesn't work I wonder if just setting it to "localhost" would satisfy what the test is trying to do.
If none of those work and we have to skip the test -- we should skip the test with a clause for Mac, probably something like:
@unittest.skipIf(sys.platform == "darwin")Doing it explicitly this way will make it easy to keep track of which tests we're skipping
Collaborator
Author
There was a problem hiding this comment.
This actually skips with a message for the dev, asking them to add the host to /etc/hosts.
I can try the other options to see if something goes through...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_announce_and_connect_via_dnswith a clear message whenlocalhost.localdomainis not resolvable (macOS omits it from/etc/hostsby default)AI_ADDRCONFIGintry_connect_one_addr()with#ifndef __APPLE__: on macOS/BSD,AI_ADDRCONFIGopens temporary probe sockets that are not tracked by theioframework, causingdev_report_fds()to report them as unowned (**BROKEN**); Linux keeps the optimization unchangedCloses #9012
Test plan
uv run pytest tests/test_gossip.py::test_announce_and_connect_via_dns -vpasses on Linuxlocalhost.localdomainin/etc/hosts: test is skipped with a descriptive messagelocalhost.localdomainin/etc/hosts: no**BROKEN**fd messages from connectd at teardown🤖 Generated with Claude Code